<div class="content-section introduction">
    <div class="feature-intro">
        <h1>Menu</h1>
        <p>Menu is a navigation / command component that supports dynamic and static positioning.</p>
    </div>
</div>

<div class="content-section implementation">
    <div class="card">
        <h5>Basic</h5>
        <p-menu [model]="items"></p-menu>
    
        <h5>Overlay</h5>
        <button type="button" pButton icon="pi pi-bars" label="Show" (click)="menu.toggle($event)"></button>
        <p-menu #menu [popup]="true" [model]="items"></p-menu>
    </div>
</div>

<div class="content-section documentation">
    <p-tabView>
        <p-tabPanel header="Documentation">
            <h5>Import</h5>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
import &#123;MenuModule&#125; from 'primeng/menu';
import &#123;MenuItem&#125; from 'primeng/api';
</app-code>

            <h5>MenuModel API</h5>
            <p>Menu uses the common menumodel api to define its items, visit <a [routerLink]="['/menumodel']">MenuModel API</a> for details.</p>

            <h5>Getting Started</h5>
            <p>Menu requires a collection of menuitems as its model.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-menu [model]="items"&gt;&lt;/p-menu&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [
            &#123;label: 'New', icon: 'pi pi-fw pi-plus'&#125;,
            &#123;label: 'Open', icon: 'pi pi-fw pi-download'&#125;,
            &#123;label: 'Undo', icon: 'pi pi-fw pi-refresh'&#125;
        ];
    &#125;
&#125;
</app-code>

            <h5>SubMenus</h5>
            <p>Menu supports 1 level of nesting via subitems of an item.</p>
<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MenuDemo &#123;
    
    items: MenuItem[];

    ngOnInit() &#123;
        this.items = [&#123;
            label: 'File',
            items: [
                &#123;label: 'New', icon: 'pi pi-fw pi-plus'&#125;,
                &#123;label: 'Download', icon: 'pi pi-fw pi-download'&#125;
            ]
        &#125;,
        &#123;
            label: 'Edit',
            items: [
                &#123;label: 'Add User', icon: 'pi pi-fw pi-user-plus'&#125;,
                &#123;label: 'Remove User', icon: 'pi pi-fw pi-user-minus'&#125;
            ]
        &#125;];
    &#125;
&#125;
</app-code>

            <h5>Popup Mode</h5>
            <p>Menu is inline by default, popup mode is also supported by enabling popup property and calling toggle method by passing the event 
                    from the anchor element.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-menu #menu [popup]="true" [model]="items"&gt;&lt;/p-menu&gt;
&lt;button type="button" pButton icon="pi pi-list" label="Show" (click)="menu.toggle($event)"&gt;&lt;/button&gt;
</app-code>

            <h5>Animation Configuration</h5>
            <p>Transition of the open and hide animations can be customized using the showTransitionOptions and hideTransitionOptions properties, 
                example below disables the animations altogether.</p>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;p-menu [showTransitionOptions]="'0ms'" [hideTransitionOptions]="'0ms'" #menu [popup]="true" [model]="items"&gt;&lt;/p-menu&gt;
&lt;button type="button" pButton icon="pi pi-list" label="Show" (click)="menu.toggle($event)"&gt;&lt;/button&gt;
</app-code>       
            <h5>Properties</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Type</th>
                        <th>Default</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>model</td>
                            <td>array</td>
                            <td>null</td>
                            <td>An array of menuitems.</td>
                        </tr>
                        <tr>
                            <td>popup</td>
                            <td>boolean</td>
                            <td>false</td>
                            <td>Defines if menu would displayed as a popup.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>appendTo</td>
                            <td>any</td>
                            <td>null</td>
                            <td>Target element to attach the overlay, valid values are "body" or a local ng-template variable of another element (note: use binding with brackets for template variables, e.g. [appendTo]="mydiv" for a div element having #mydiv as variable name).</td>
                        </tr>
                        <tr>
                            <td>baseZIndex</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Base zIndex value to use in layering.</td>
                        </tr>
                        <tr>
                            <td>autoZIndex</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to automatically manage layering.</td>
                        </tr>
                        <tr>
                            <td>showTransitionOptions</td>
                            <td>string</td>
                            <td>.12s cubic-bezier(0, 0, 0.2, 1)</td>
                            <td>Transition options of the show animation.</td>
                        </tr>
                        <tr>
                            <td>hideTransitionOptions</td>
                            <td>string</td>
                            <td>.1s linear</td>
                            <td>Transition options of the hide animation.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Events</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onShow</td>
                            <td>event: Event object</td>
                            <td>Callback to invoke when overlay menu is shown.</td>
                        </tr>
                        <tr>
                            <td>onHide</td>
                            <td>event: Event object</td>
                            <td>Callback to invoke when overlay menu is hidden.</td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <h5>Methods</h5>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Parameters</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>toggle</td>
                            <td>event: browser event</td>
                            <td>Toggles the visibility of the popup menu.</td>
                        </tr>
                        <tr>
                            <td>show</td>
                            <td>event: browser event</td>
                            <td>Displays the popup menu.</td>
                        </tr>
                        <tr>
                            <td>hide</td>
                            <td>-</td>
                            <td>Hides the popup menu.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Styling</h5>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Element</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>p-menu</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>p-menu-list</td>
                            <td>List element.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem</td>
                            <td>Menuitem element.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem-text</td>
                            <td>Label of a menuitem.</td>
                        </tr>
                        <tr>
                            <td>p-menuitem-icon</td>
                            <td>Icon of a menuitem.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h5>Dependencies</h5>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/menu" class="btn-viewsource" target="_blank">
                <span>View on GitHub</span>
            </a>
            <a href="https://stackblitz.com/edit/primeng-menu-demo" class="btn-viewsource" style="margin-left: .5em;" target="_blank">
                <span>Edit in StackBlitz</span>
            </a>
<app-code lang="markup" ngNonBindable ngPreserveWhitespaces>
&lt;h5&gt;Basic&lt;/h5&gt;
&lt;p-menu [model]="items"&gt;&lt;/p-menu&gt;

&lt;h5&gt;Overlay&lt;/h5&gt;
&lt;button type="button" pButton icon="pi pi-bars" label="Show" (click)="menu.toggle($event)"&gt;&lt;/button&gt;
&lt;p-menu #menu [popup]="true" [model]="items"&gt;&lt;/p-menu&gt;
</app-code>

<app-code lang="typescript" ngNonBindable ngPreserveWhitespaces>
export class MenuDemo &#123;

    items: MenuItem[];

    constructor(private messageService: MessageService) &#123;&#125;

    ngOnInit() &#123;
        this.items = [&#123;
            label: 'Options',
            items: [&#123;
                label: 'Update',
                icon: 'pi pi-refresh',
                command: () =&gt; &#123;
                    this.update();
                &#125;
            &#125;,
            &#123;
                label: 'Delete',
                icon: 'pi pi-times',
                command: () =&gt; &#123;
                    this.delete();
                &#125;
            &#125;
            ]&#125;,
            &#123;
                label: 'Navigate',
                items: [&#123;
                    label: 'Angular Website',
                    icon: 'pi pi-external-link',
                    url: 'http://angular.io'
                &#125;,
                &#123;
                    label: 'Router',
                    icon: 'pi pi-upload',
                    routerLink: '/fileupload'
                &#125;
            ]&#125;
        ];
    &#125;

    update() &#123;
        this.messageService.add(&#123;severity:'success', summary:'Success', detail:'Data Updated'&#125;);
    &#125;

    delete() &#123;
        this.messageService.add(&#123;severity:'warn', summary:'Delete', detail:'Data Deleted'&#125;);
    &#125;

&#125;
</app-code>
        </p-tabPanel>
        <p-tabPanel header="StackBlitz">
            <ng-template pTemplate="content">
                <iframe src="https://stackblitz.com/edit/primeng-menu-demo?embed=1" style="width: 100%; height: 768px; border: none;"></iframe>
            </ng-template>
        </p-tabPanel>
    </p-tabView>
</div>